<?php
/**
 * 金银拼列表
 *
 *
 *
 * * @网店运维 (c) 2015-2018  Inc. (http://www.shopwwi.com)
 * @license    http://www.shopwwi.c om
 * @link       交流群号：111731672
 * @since      网店运维提供技术支持 授权请购买shopnc授权
 */



defined('InShopNC') or exit('Access Invalid!');
class store_piaoControl extends BaseSellerControl {
    public function __construct() {
        parent::__construct();
        Language::read ('member_store_goods_index');
    }

    public function indexOp() {
        $model_member = Model('member');
        $condition = array();
        $curpage = empty($_GET['curpage']) ? 1:(int)$_GET['curpage'];
        $condition['member_piao'] = 1;
        if(!empty($_GET['keyword'])) {
            $condition['member_truename|member_mobile'] = array('like', '%'.$_GET['keyword'].'%');
        }
        $item_count = $model_member->getMemberCount($condition);
        Tpl::output('item_count',$item_count);
        $item_list = $model_member->getMemberList($condition, '*', 'id desc',10,$curpage-1);
        Tpl::output('item_list', $item_list);
        Tpl::output('show_page', $model_member->showpage(2));

        Tpl::showpage('store_piao.list');
    }

    public function addOp(){
        if (chksubmit()){
            $model_member = Model("member");
            $result = $model_member->where(array('member_id'=>(int)$_POST['member_id'],'member_name'=>$_POST['member_name']))->update(array('member_piao'=>1,'piao_time'=>time()));
            if($result){
                $this->recordSellerLog('用户'.$_POST['member_mobile'].' 领用矿博会门票');
                showDialog('门票发放成功', urlShop('store_piao', 'index'), 'succ');
            }
        }else {
            Tpl::showpage('store_piao.add', 'null_layout');
        }
    }

    public function check_member_ajaxOp(){
        $model_member = Model("member");
        $keyword = $_GET['keyword'];
        $member= $model_member->where(array('member_mobile|member_carid'=>$keyword))->find();
        echo json_encode($member);
        exit;
    }

}
